package com.course.web.view;

import com.course.web.component.custom.SpecWeekGrid;
import com.course.web.page.AdminUI;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.spring.annotation.SpringView;
import com.vaadin.ui.CustomComponent;
import org.apache.commons.lang3.math.NumberUtils;

/**
 * Created by Justin on 2017/5/14.
 */
@SpringView(name = SpecWeekView.NAME, ui = AdminUI.class)
public class SpecWeekView extends CustomComponent implements View {
    public static final String NAME = "spec-week";

    private final SpecWeekGrid specWeekGrid;

    public SpecWeekView(SpecWeekGrid specWeekGrid) {
        this.specWeekGrid = specWeekGrid;
        setCompositionRoot(specWeekGrid);
        setSizeFull();
    }

    @Override
    public void enter(ViewChangeListener.ViewChangeEvent event) {
        String parameters = event.getParameters();
        int specId = NumberUtils.toInt(parameters);
        specWeekGrid.enter(specId);
    }
}
